import React, {Component,PropTypes,PureComponent} from 'react';
import {connect} from 'dva';
import {routerRedux,Link,withRouter } from 'dva/router';

import LoginForm from './components/LoginForm';
import Loading from '../../components/common/Loading';

import styles from './home.less';

const toLogin = globalLoading => query => ({
	type: 'login/login',
	payload: query,
	loading: globalLoading,
});

const mapStateToProps = state => ({
	...state.app,
	userInfo: state.login.userInfo,
	loading: state.loading.global,
});

const mapDispatchToProps = {
	login: toLogin(true),
	logout: () => ({
		type: 'login/logout'
	})
};

@withRouter
@connect(mapStateToProps, mapDispatchToProps)
export default class Home extends PureComponent {
	static propTypes ={
		loading: PropTypes.bool.isRequired,
		logout: PropTypes.func.isRequired,
	}

	componentDidMount(){
		const { logout } =this.props;
		logout();
	}

	render() {
		const {loading} = this.props
		return (
			<div className={styles.loginPage}>
				<Loading loading={loading} />
			 <LoginForm {...this.props} />
			 {/* <iframe style={{display:'none'}} src="http://168.61.13.30:8080/thfx/ReportServer?op=fs_load&cmd=ssout"></iframe> */}
			</div>
		);
	}
}
